package com.zh.note.huawei.onehundred.找出同班小朋友分班;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @Author: zhanghuan
 * @date: 2023/9/2 22:28
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // String line = sc.nextLine();
        String line = "1/N 2/Y 3/N 4/Y";
        String[] lines = line.split(" ");
        List<Integer> list1 = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        int flag = 1;//第一一个标志，表示前一个元素是在哪一个里面
        for (int i = 0; i < lines.length; i++) {
            String[] split = lines[i].split("/");
            if (i == 0) {
                list1.add(Integer.parseInt(split[0]));
                flag = 1;
                continue;
            }
            if (flag == 1) {
                if ("Y".equals(split[1])) {
                    list1.add(Integer.parseInt(split[0]));
                } else {
                    list2.add(Integer.parseInt(split[0]));
                    flag = 2;
                }
            } else {//前一个元素在第二个里面
                if ("Y".equals(split[1])) {
                    list2.add(Integer.parseInt(split[0]));
                } else {
                    list1.add(Integer.parseInt(split[0]));
                    flag = 1;
                }
            }

        }
        Collections.sort(list1);
        Collections.sort(list2);
        for (int i = 0; i < list1.size(); i++) {
            System.out.print(list1.get(i) + " ");
        }
        System.out.println();
        for (int i = 0; i < list2.size(); i++) {
            System.out.print(list2.get(i) + " ");
        }

    }
}
